import type {
  DepartData,
  OrderDetail,
  OrderParams,
  OrderPreData,
  OrderPreParams,
  PayParams,
  UploadImage,
} from '@/types/consult'
import type { RateParams } from '@/types/room'
import request from '@/utils/request'

/**
 * 医生科室列表
 */
export const departmentListApi = () => {
  return request.get<null, DepartData[]>('/dep/all')
}

export const uploadImageApi = (filePath: string) => {
  return request.upload<null, UploadImage>('/upload', {
    filePath,
    name: 'file',
  })
}

/** 获取问诊-预支付订单数据 */
export const preOrderApi = (params: OrderPreParams) => {
  return request.get<null, OrderPreData>('/patient/consult/order/pre', {
    params,
  })
}

/**
 * 生成待支付订单
 */
export const createOrderApi = (data: OrderParams) => {
  return request.post<null, { id: string }>('/patient/consult/order', data)
}

/**
 * 三方支付（暂时只支持支付宝支付）
 */
export const orderPayApi = (data: PayParams) => {
  return request.post<null, { payUrl: string }>('/patient/consult/pay', data)
}

/**
 * 问诊订单详情
 */
export const orderDetailApi = (orderId: string) => {
  return request.get<null, OrderDetail>('/patient/consult/order/detail', { params: { orderId } })
}

// 2.封装API
/** 评价医生 */
export const evaluateDoctorApi = (data: RateParams) => {
  return request.post('/patient/order/evaluate', data)
}
